import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 商品信息
 */
@Entity('mall_goods')
export class MallGoodsEntity extends BaseEntity {
  @Index()
  @Column({ comment: '分类ID' })
  categoryId: number;

  @Column({ comment: '标题', length: 255 })
  title: string;

  @Column({ comment: '主图', length: 255, nullable: true })
  pic: string;

  @Column({ comment: '示例图', type: 'json', nullable: true })
  images: string[];

  @Column({
    comment: '价格',
    type: 'decimal',
    precision: 10,
    scale: 2,
    default: 0,
  })
  price: number;

  @Column({ comment: '产地', length: 255, nullable: true })
  origin: string;

  @Column({ comment: '状态', dict: ['下架', '上架'], default: 1 })
  status: number;

  @Column({ comment: '详情', type: 'text', nullable: true })
  content: string;

  @Column({ comment: '排序值', default: 0 })
  order: number;
}
